home *** CD-ROM | disk | FTP | other *** search
- #pragma once
- #include <QDOffscreen.h>
- #include <TObjectQueue.h>
- #include <retrace.h>
- #include "LockPixMap.h"
- #include "MHeapObject.h"
- #include "A5World.h"
-
- class StSaveGWorld
- {
- public:
- StSaveGWorld();
- ~StSaveGWorld();
-
-
- protected:
- GWorldPtr fSaveGWorld;
- GDHandle fSaveGD;
- };
-
- class CSprite;
- class CSpriteCanvas;
-
- class CSpriteWorld
- {
- friend class CSprite;
- public:
- CSpriteWorld(OSErr& err);
- ~CSpriteWorld();
-
- void Start();
- void Stop();
-
- CSpriteCanvas* GetSpriteCanvas() {return fCanvas;}
- CSpriteCanvas* GetBackgroundCanvas() {return fBackground;}
-
- TObjectQueue<CSprite>& GetSpriteQueue() {return fSpriteQueue;}
-
- void Idle(); // DONT CALL THIS, this is public for debugging only
-
- protected:
- void AddSprite(CSprite* sprite);
- void RemoveSprite(CSprite* sprite);
-
- void UpdateSpriteLocations();
- void DrawAll();
- void DrawBackground();
- void DrawSprites();
- void CheckForHits();
- void CheckForHitsOnThisSprite(CSprite* thisOne);
-
- virtual void ImageBackground(CSpriteCanvas* canvas);
-
- enum{ kInterval = 3};
- struct ExtendedVBL : VBLTask
- {
- long saveGlobals;
- CSpriteWorld* thisObj;
- };
-
- static void _VBLTask();
- void InstallVBL();
- void RemoveVBL();
-
- TObjectQueue<CSprite> fSpriteQueue;
- CSpriteCanvas* fBackground;
- CSpriteCanvas* fCanvas;
- PixMapHandle fMainPixMap;
- char fDeviceState;
- PixMapState fMainPixMapState;
- Boolean fVBLInstalledQ;
- ExtendedVBL fVBL;
- A5World fA5World;
-
- };
-
-
- class CSpriteCanvas
- {
- public:
- CSpriteCanvas(OSErr& err);
- ~CSpriteCanvas();
-
- const Rect* GetBounds() {return &fBounds;}
- void Blit(PixMapHandle pm,
- const Rect& inSourceRect,
- const Rect& inDestRect,
- RgnHandle inSourceMask);
-
- PixMapHandle GetPixMap() {return fPixMap;}
- GWorldPtr GetGWorld() {return fGWorld;}
-
- void PrepareToDraw();
- protected:
- GWorldPtr fGWorld;
- PixMapHandle fPixMap;
- Rect fBounds;
- };
-
-
- class CSprite : public TQueueElem<CSprite> ,
- public MHeapObject
- {
- public:
- CSprite(CSpriteWorld* theWorld,long id,const Rect& inStart);
- virtual ~CSprite();
-
-
- virtual void UpdatePosition() = 0;
- virtual void Draw() = 0;
- virtual Boolean WasHitBy(CSprite* hitByThis) {return true;};
-
- long GetID() {return fID;}
- Rect* GetLocation() {return &fLocation;}
- short Width() {return fLocation.right - fLocation.left;}
- short Height() {return fLocation.bottom - fLocation.top;}
-
- void MoveBy(short dX,short dY) {OffsetRect(&fLocation,dX,dY);}
- void MoveTo(short x,short y) {OffsetRect(&fLocation,
- x - fLocation.left,
- y - fLocation.top); }
- Boolean OutOfBoundsQ();
- void MoveToH(short h) {OffsetRect(&fLocation,h - fLocation.left,0);}
- void MoveToV(short v) {OffsetRect(&fLocation,0,v - fLocation.top);}
-
- CSpriteWorld* GetWorld() {return fWorld;}
- const Rect* GetGameBounds();
-
- protected:
-
- Boolean KeyIsDownQ(short keyCode);
-
-
- long fID;
- Rect fLocation;
- CSpriteWorld* fWorld;
-
- private:
-
- };
-
-
- class CPixMapSprite : public CSprite
- {
- public:
- CPixMapSprite(CSpriteWorld* world,long id,GWorldPtr image,
- short startTop,short startLeft,RgnHandle mask);
- virtual ~CPixMapSprite();
-
- void SetImage(GWorldPtr image,RgnHandle mask);
- virtual void Draw();
-
- protected:
- PixMapHandle fPixMap;
- GWorldPtr fGWorld;
- RgnHandle fSourceMask;
- };
-
- class CHPixMapSprite : public CPixMapSprite
- {
- public:
- CHPixMapSprite(CSpriteWorld* world,long id,GWorldPtr image,
- short startTop,short startLeft,RgnHandle mask);
-
- virtual ~CHPixMapSprite();
-
- virtual void UpdatePosition();
-
- };
-
-
-